package com.daniel.design.principles.demo3.after;

/**
 * @ClassName Computer
 * @Description 组装电脑类
 * @Author Daniel
 * @Version V1.0.0
 */
public class Computer {

    private HardDisk mHardDisk;

    private Cpu mCpu;

    private Memory mMemory;

    public void setHardDisk(HardDisk hardDisk) {
        mHardDisk = hardDisk;
    }

    public void setCpu(Cpu cpu) {
        mCpu = cpu;
    }

    public void setMemory(Memory memory) {
        mMemory = memory;
    }

    public void run() {
        System.out.println("电脑开始运行");
        mCpu.run();
        mMemory.save();
        mHardDisk.save("你好");
        mHardDisk.read();
    }

    public static void main(String[] args) {
        Computer computer = new Computer();
        computer.setCpu(new IntelCpu());
        computer.setMemory(new KingsMemory());
        computer.setHardDisk(new XiBuHardDisk());

        computer.run();
    }
}
